package com.urerp.web.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.urerp.web.common.MenuUtil;
import com.urerp.web.common.SessionUtil;

@Controller
public class CommonController {
	
	private static final Logger logger = LogManager.getLogger(CommonController.class);
	
	@Autowired
	private MenuUtil menuUtil;
	
    // 세션 여부 확인
	@RequestMapping(value = "common/sessionInfo", method = RequestMethod.POST)
    public @ResponseBody String sessionInfo() {
		
		logger.debug("RequestMapping : /sessionInfo, Method : sessionInfo");
		
		/**
		 * return
		 *  0 - 세션 있음
		 *  9 - 세션 없음
		 */
		
		if(SessionUtil.getSession()) {
			return "0";
		}
		
        return "9";
        
	}
	
	// 메뉴 세팅
	@RequestMapping(value = "common/menuSetting", method = RequestMethod.GET)
    public String menuSetting() {
		
		logger.debug("RequestMapping : /menuSetting, Method : menuSetting");
		
		menuUtil.setMenu();
		
        return "redirect:/";
        
	}
	
	 
}
